﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using EOrder_Entities;
using EOrder_Entities.WrapperClasses;

namespace EOrder_WCF
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        /// <summary>
        /// Sample service
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        [OperationContract]
        string GetData(int value);

        /// <summary>
        /// Sample service
        /// </summary>
        /// <param name="composite"></param>
        /// <returns></returns>
        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        /// <summary>
        /// Update latest data from server
        /// </summary>
        /// <returns>File path of SQLite file that contains data</returns>
        [OperationContract]
        string SyncData();

        /// <summary>
        /// Get all the tables and their statuses
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        Table[] GetTables();

        /// <summary>
        /// Create new order
        /// </summary>
        /// <param name="order">New order to be created</param>
        /// <returns>value indicating the process is successful or not</returns>
//        [OperationContract]
//        bool CreateOrder(Order order);

        [OperationContract]
        bool CreateOrder(string orderDetailString, string orderItemListString);

        /// <summary>
        /// Get the order of a specific table
        /// </summary>
        /// <param name="tableId">id of the table we want to view order</param>
        /// <returns></returns>
        [OperationContract]
        Order GetOrder(int tableId);

        /// <summary>
        /// Update data of a current order
        /// </summary>
        /// <param name="order">updated order</param>
        /// <returns>value indicating the process is successful or not</returns>
        [OperationContract]
        bool UpdateOrder(Order order);

        /// <summary>
        /// Group many orders into one
        /// </summary>
        /// <param name="orderIds"></param>
        /// <returns></returns>
        [OperationContract]
        bool GroupOrders(int[] orderIds);

//        /// <summary>
//        /// Update data of some order items
//        /// </summary>
//        /// <param name="orderItems">updated order items</param>
//        /// <returns>value indicating the process is successful or not</returns>
//        [OperationContract]
//        bool UpdateOrderItems(List<OrderItem> orderItems);

        /// <summary>
        /// Add some order items
        /// </summary>
        /// <param name="orderItems">order items to be added</param>
        /// <returns>value indicating the process is successful or not</returns>
        [OperationContract]
        bool AddOrderItems(List<OrderItem> orderItems);

        /// <summary>
        /// notify that the customers of this order want to pay
        /// </summary>
        /// <param name="orderId">id of the order to be paid</param>
        /// <returns>value indicating the process is successful or not</returns>
        [OperationContract]
        bool RequestBill(int orderId);

        /// <summary>
        /// move an order to another table
        /// </summary>
        /// <param name="oldTableId">id of the old table</param>
        /// <param name="newTableId">id of the old table</param>
        /// <returns>value indicating the process is successful or not</returns>
        [OperationContract]
        bool ChangeTable(int oldTableId, int newTableId);
        
        /// <summary>
        /// Group many tables to 1 group
        /// </summary>
        /// <param name="mainTableId">id of the main table, which will be the group number</param>
        /// <param name="otherTableIds">ids of other tables in the group</param>
        /// <returns>value indicating the process is successful or not</returns>
        [OperationContract]
        bool GroupTables(int mainTableId, List<int> otherTableIds);

        /// <summary>
        /// Separate tables from a group
        /// </summary>
        /// <param name="groupNumber">group number of the group to be separated</param>
        /// <returns>value indicating the process is successful or not</returns>
        [OperationContract]
        bool UnGroupTables(int groupNumber);

        /// <summary>
        /// Submit customers' feedback
        /// </summary>
        /// <param name="orderId">order id of the customers who give feedback</param>
        /// <param name="comment">comment of customers</param>
        /// <returns>value indicating the process is successful or not</returns>
        [OperationContract]
        bool SendFeedback(int orderId, string comment);
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }
}
